import vue from "@vitejs/plugin-vue";
import { visualizer } from "rollup-plugin-visualizer";
import Components from "unplugin-vue-components/vite";
// import { chunkSplitPlugin } from 'vite-plugin-chunk-split'; // 没有对应版本
import minipic from "vite-plugin-minipic";

import { AntDesignVueResolver, ElementPlusResolver } from "unplugin-vue-components/resolvers"; // 自动导入ant-design-vue组件的
import createAutoImport from "./auto-import";
import createSvgIcon from "./svg-icon";
import createCompression from "./compression";
// import createSetupExtend from './setup-extend'
import VueJsx from "@vitejs/plugin-vue-jsx";

export default function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [
    vue(),
    VueJsx(),
    // chunkSplitPlugin()
    minipic(),
    // visualizer(),
    //开启这个会导致 报告页面 icon 出不来
    Components({
      resolvers: [
        // AntDesignVueResolver({
        //     // resolveIcons: true,
        // }),
        ElementPlusResolver(),
      ],
    }),
  ];
  vitePlugins.push(createAutoImport());
  // vitePlugins.push(createSetupExtend())
  vitePlugins.push(createSvgIcon(isBuild));
  isBuild && vitePlugins.push(...createCompression(viteEnv));
  return vitePlugins;
}
